//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================

#include "utils.h"
#include "consolewindow.h"

/* Check if c is a space */
Boolean isspace(WChar c)
{
    return (c == L' ');
}

/* Strip left spaces */
PWChar ltrim(PWChar str)
{
    WChar c;
    assert(str);
    while ((c = *str++) != '\0' && isspace(c))
    ;

    return (PWChar)str - 1;      /* strip const */
}

/* Strip right spaces */
Void rtrim(PWChar const str)
{
    PWChar p = NULL;

    assert(str);

    p = wcschr(str, '\0');
    if (p == NULL) return ;
    while (--p >= str && isspace(*p))
    ;
    p[1] = '\0';
}

/* Strip right and left spaces */
PWChar trim(PWChar str)
{
    assert(str);
    rtrim(str);
    return ltrim(str);
}
